<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class sk_model extends CI_Model {
    public function __construct() {
        parent::__construct();
        $this->load->database();
    }
    public function get_cap() {
        $query = $this->db->query("SELECT * from tb_officials where official_position_id_fk=5 && official_barangay_id_fk =".$this->session->userdata('barangay_id'));
        return $query->result();
    }
    public function get_sec(){
        $query= $this->db->query("SELECT * from tb_officials where official_position_id_fk=7 && official_barangay_id_fk =" .$this->session->userdata('barangay_id'));
        return $query->result();
    }
    public function get_tre(){
        $query= $this->db->query("SELECT * from tb_officials where official_position_id_fk=8 && official_barangay_id_fk = ".$this->session->userdata('barangay_id'));
        return $query->result();
    }
    public function get_coun(){
        $query= $this->db->query("SELECT * from tb_officials where official_position_id_fk=6 && official_barangay_id_fk =".$this->session->userdata('barangay_id'));
        return $query->result();
    }
    public function get_official(){
        $id = $this->input->get('id');
        $query= $this->db->query("SELECT * from tb_officials where official_id_pk=".$id." && official_barangay_id_fk = ".$this->session->userdata('barangay_id'));
        return $query->result();
    }
    public function edit(){
        $id = $this->input->post('id');
        $f_name = $this->input->post('f_name');
        $m_name = $this->input->post('m_name');
        $l_name = $this->input->post('l_name');
        $query= $this->db->query("UPDATE tb_officials SET official_firstname ='".$f_name."', official_middlename='".$m_name."',official_lastname='".$l_name."' where official_id_pk=".$id." && official_barangay_id_fk =".$this->session->userdata('barangay_id'));
        
    }
    
    
}
